package com.kmproject.haifu.mvp.ui.adapter;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.kmproject.haifu.mvp.model.entity.beans.MemberCenterUserInfoBean;
import com.kmproject.haifu.mvp.ui.fragment.MemberUpdatelevelPaymentFragment;

import java.lang.reflect.Member;
import java.util.List;

public class FragmentTitlesAdapter extends FragmentPagerAdapter {
    private List<String> titles;
    private Activity activity;
    private
    List<Fragment> fragments;
    List<MemberCenterUserInfoBean.MemberLevelBean> mmemberLevelBeans;
    public FragmentTitlesAdapter(FragmentManager fm, Activity activity,   List<MemberCenterUserInfoBean.MemberLevelBean> memberLevelBeans) {
        super(fm);
        this.mmemberLevelBeans=memberLevelBeans;
        this.activity=activity;
        this.fragments=fragments;
    }
    public FragmentTitlesAdapter(FragmentManager fm, Activity activity, List<String>  titles, List<Fragment>  fragments) {
        super(fm);
        this.titles=titles;
         this.activity=activity;
         this.fragments=fragments;
    }

    @Override
    public Fragment getItem(int i) {
        if (mmemberLevelBeans!=null&&!mmemberLevelBeans.isEmpty())
        {
            return MemberUpdatelevelPaymentFragment.newInstance(i,mmemberLevelBeans.get(i));
        }
        return fragments.get(i);
    }
    @Override
    public CharSequence getPageTitle(int position) {
        if (mmemberLevelBeans!=null&&!mmemberLevelBeans.isEmpty())
        {
            return mmemberLevelBeans.get(position).getLevelName();
        }
        return titles.get(position);
    }

    @Override
    public int getCount() {
        if (mmemberLevelBeans!=null&&!mmemberLevelBeans.isEmpty())
        {
            return mmemberLevelBeans.size();
        }
        return titles.size();
    }
}
